package com.api.server.controller;


import com.api.server.pojo.*;
import com.api.server.service.IUserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shi
 * @since 2022-04-28
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @Autowired
    HttpServletRequest req;

    // 普通用户注册

    @ApiOperation(value = "普通用户注册")
    @PostMapping
    public Result registeruser(@RequestBody Puser puser){
        if (userService.getAdminByUserName(puser.getUseraccount())!=null){
            return Result.fail("该用户名已经被使用！");

        }
        userService.registeruser(puser);
        puser.setUserpassword(null);
        return Result.success(201,"用户创建成功",puser);
    }




}
